export const columns = context => {
  return [
    {
      prop: 'realName',
      label: '员工姓名',
      minWidth: 120
    },
    {
      prop: 'userName',
      label: '账号',
      minWidth: 120
    },
    {
      prop: 'mobile',
      label: '手机号',
      minWidth: 120
    },
    {
      prop: 'apartmentName',
      label: '部门',
      minWidth: 120
    },
    {
      prop: 'roleName',
      label: '岗位',
      minWidth: 120
    },
    {
      label: '账号状态',
      minWidth: 160,
      render: (h, row) => {
        return [
          <zm-switch
            value={row.status}
            active-value="1"
            inactive-value="2"
            onChange={() => context.onSwitch(row)}
          />
        ]
      }
    },
    {
      label: '操作',
      width: 280,
      fixed: 'right',
      render: (h, row) => {
        return [
          <el-button type="text" onClick={() => context.onDetail(row)}>
            详情
          </el-button>,
          <el-button type="text" onClick={() => context.onEdit(row)}>
            编辑
          </el-button>,
          <el-button
            type="text"
            class="text-error"
            onClick={() => context.onDelete(row)}
          >
            删除
          </el-button>,
          <el-button type="text" onClick={() => context.resetPassword(row)}>
            重置密码
          </el-button>,
          <el-button type="text" onClick={() => context.transfer(row)}>
            移交
          </el-button>
        ]
      }
    }
  ]
}

export const formRule = {
  realName: [
    {
      required: true,
      message: '请输入员工姓名',
      trigger: 'blur'
    }
  ],
  userName: [
    {
      required: true,
      message: '请输入员工账号',
      trigger: 'blur'
    },
    {
      pattern: /^([A-Z]|[a-z]|[\d])*$/,
      message: '只允许输入英文和数字',
      trigger: 'blur'
    }
  ],
  mobile: [
    {
      required: true,
      message: '请输入手机号',
      trigger: 'blur'
    },
    {
      pattern: /^\d{7,12}$/,
      message: '请输入正确的手机号',
      trigger: 'blur'
    }
  ],
  userId: [
    {
      required: true,
      message: '请选择移交人员',
      trigger: 'blur'
    }
  ],
  select: [
    {
      required: true,
      message: '请选择销售单',
      trigger: 'blur'
    }
  ],
  companyId: [
    {
      required: true,
      message: '请选择公司',
      trigger: 'blur'
    }
  ],
  apartmentId: [
    {
      required: true,
      message: '请选择所属部门',
      trigger: 'blur'
    }
  ],
  roleId: [
    {
      required: true,
      message: '请选择所属岗位',
      trigger: 'blur'
    }
  ]
}
